/** 节流阀，用于修饰被调用函数，被修饰的函数在delay毫秒内只能调用一次 */
export function throttle(delayMs: number) {
	let lastClick = 0;
	return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
		const originMethos = descriptor.value;
		descriptor.value = function (...args: any[]) {
			const now = Date.now();
			if (now - lastClick >= delayMs) {
				lastClick = now;
				originMethos.apply(this, args);
			} else {
				console.log("调用太频繁，稍后再试");
			}
		}
	}
}